#include "EPSG/Environ.h"

/* System Includes */
#ifdef WIN32
	#include <Windows.h>
#endif

/* OpenGL Includes */
#include <GL/GL.h>

EPSG::Environ::Environ()
{
}

void EPSG::Environ::setFogMode( FogMode mode )
{
	if( mode == EPSG_EXP )
		_mode = GL_EXP;
	else if( mode == EPSG_EXP2 )
		_mode = GL_EXP2;
	else if( mode == EPSG_LINEAR )
		_mode = GL_LINEAR;
}

void EPSG::Environ::setFogColor( float r, float g, float b, float a )
{
	_color[0] = r;
	_color[1] = g;
	_color[2] = b;
	_color[3] = a;
}

void EPSG::Environ::setFogDensity( float density )
{
	_density = density;
}

void EPSG::Environ::setFogHint( FogHint hint )
{
	if( hint == EPSG_DONT_CARE )
		_hint = GL_DONT_CARE;
	else if( hint == EPSG_FASTEST )
		_hint = GL_FASTEST;
	else if( hint == EPSG_NICEST )
		_hint = GL_NICEST;
}

void EPSG::Environ::setFogStart( float start )
{
	_start = start;
}

void EPSG::Environ::setFogEnd( float end )
{
	_end = end;
}

void EPSG::Environ::load()
{
	glPushAttrib( GL_FOG_BIT );
	glEnable( GL_FOG );

	glFogi( GL_FOG_MODE, _mode );
	glFogfv( GL_FOG_COLOR, _color );
	glFogf( GL_FOG_DENSITY, _density );
	glFogf( GL_FOG_START, _start );
	glFogf( GL_FOG_END, _end );
	glHint( GL_FOG_HINT, _hint );
}

void EPSG::Environ::unload()
{
	glPopAttrib();
}